//
//  MHHomeMainHeaderView.m
//  ManHua
//
//  Created by 江子安 on 15/10/26.
//  Copyright © 2015年 蓝欧科技. All rights reserved.
//

#import "MHHomeMainHeaderView.h"

@implementation MHHomeMainHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _scrollView = [[UIScrollView alloc]initWithFrame:self.bounds];
        _scrollView.contentSize = CGSizeMake(SCREEN_WIDTH * 6, 0);
        _scrollView.pagingEnabled = YES;
        
        
        for (int i = 0; i < 6; i++) {
            UIButton *imgBtn = [UIButton buttonWithType:UIButtonTypeSystem];
            imgBtn.frame = CGRectMake(i * SCREEN_WIDTH, 0, SCREEN_WIDTH, self.bounds.size.height);
            
            [_scrollView addSubview:imgBtn];
        }
        _scrollView.delegate = self;
        
        [self addSubview:_scrollView];
        
        _titleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        
        float height = self.bounds.size.height;
        float width = SCREEN_WIDTH;
        _titleBtn.frame = CGRectMake(0, height/4*3, width/4*3, height/8);
        [self addSubview:_titleBtn];
        
        _descBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _descBtn.frame = CGRectMake(0, height/8*7, width/4*3, height/8);
        [self addSubview:_descBtn];
        
        
        _pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 * 3 , 175, width/4, 25)];
        _pageControl.numberOfPages = 6;
        _pageControl.currentPage = 0;
        
        [self addSubview:_pageControl];
    }
    return self;
}


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    self.pageControl.currentPage = scrollView.contentOffset.x / SCREEN_WIDTH;
}



@end
